package com.example.springboot.service;

import com.example.springboot.entity.User;
import com.example.springboot.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    public int insertUser(User user) {
        if(user.getId() == null) {
            //没有id，插入
            return userMapper.insert(user);
        } else {//有id，更新
            return userMapper.update(user);
        }
    }

}